<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class StorelocatorTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('storelocator')) {
            // Create table for storelocator
            Schema::create('storelocator', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*门店名*/
                $table->integer('city')->unsigned();/*城市ID*/
                $table->string('address')->nullable();/*地址*/
                $table->string('phone')->nullable();/*联系电话*/
                $table->boolean('top')->default(false);/*置顶*/
                $table->string('img')->nullable();/*门店图*/
                $table->string('img_url')->nullable();/*门店图URL*/
                $table->string('tag')->nullable();/*标签 序列化*/
                $table->integer('act')->unsigned();/*活动ID*/
                $table->string('code')->nullable();/*门店代码*/
                $table->string('type')->nullable();/*门店类型*/
                $table->string('lat')->nullable();/*经度*/
                $table->string('lng')->nullable();/*维度*/
                $table->boolean('is_enable')->default(false);/*是否启用*/
            });
            Schema::create('storelocator_citys', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*城市名*/
                $table->string('lat')->nullable();/*经度*/
                $table->string('lng')->nullable();/*维度*/
                $table->string('letter')->nullable();/*首字母*/
            });
            Schema::create('storelocator_acts', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*活动名*/
                $table->string('url')->nullable();/*活动链接*/
                $table->string('file')->nullable();/*活动图片*/
                $table->string('file_url')->nullable();/*活动图片URL*/
                $table->integer('act_starttime')->unsigned();/*活动开始时间*/
                $table->integer('act_endtime')->unsigned();/*活动结束时间*/
            });
            Schema::create('storelocator_tags', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name')->unique();/*标签名*/
                $table->string('url')->nullable();/*标签链接*/
                $table->string('file')->nullable();/*标签图*/
                $table->string('file_url')->nullable();/*标签图URL*/
                $table->string('top')->default(false);/*3公里优先*/
                $table->string('point_img')->default(false);/*是否使用标签图片做定位点图片*/
                $table->integer('sort')->unsigned();/*序号*/
                $table->string('code')->nullable();/*标签代码*/
            });
            Schema::create('storelocator_settings', function (Blueprint $table) {
                $table->string('key')->unique();
                $table->string('value')->nullable();
            });
            Schema::create('storelocator_search', function (Blueprint $table) {
                $table->integer('city')->unsigned();/*城市ID*/
                $table->integer('shop_id')->unsigned();/*店铺ID*/
                $table->string('shop_name')->nullable();/*联系电话*/
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('storelocator_tags');
        Schema::drop('storelocator');
    }
}